package demo.practice;

public class P852 {

    public static void main(String[] args) {
        P852 p852= new P852();
        p852.peakIndexInMountainArray(new int[]{0,1,0});
    }
    public int peakIndexInMountainArray(int[] arr) {

        int min=0;
        int max=arr.length-1;



        while(min<max){
            int mid= min+(max-min)/2;

            if( mid+1<=arr.length-1&&         arr[mid]<  arr[mid+1]  )
                min=mid+1;

            else if(mid-1>=0  &&arr[mid] < arr[mid-1]    )
                max= mid-1;
            else
                return mid;
        }

        return min;
    }
}
